package com.nowcoder.community.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = true)
public class Comment extends LikeCountEntity{
    @TableId(type = IdType.AUTO)
    private Integer id;


    private Integer userId;
    private String content;
    private Integer entityType;
    private Integer entityId;
    private Integer targetId;
    private Integer status;
    private Date createTime;

    /**
     * 评论所属用户
     */
    @TableField(exist = false)
    private User user;

    /**
     * 评论目标用户
     */
    @TableField(exist = false)
    private User target;

    /**
     * 评论回复
     */
    @TableField(exist = false)
    private List<Comment> replies;

    public int getReplyCount() {
        if (replies == null) { return 0; }
        return replies.size();
    }
}
